<template>
	<view>

		<view style="width: 700rpx;margin:40rpx auto;">
			<u-search placeholder="搜索" v-model="initial.parm.keywords" @change="change"></u-search>
			
			<u-swipe-action :show="item.show" :index="index" v-for="(item, index) in list" :key="item.id" @click="click"
				@open="open" :options="options">
				<view class="u-padding-20 u-border-bottom"
					style="box-shadow: 0px 2px 8px 0px rgba(197,197,197,0.30);width: 700rpx;">
					<view class=" u-margin-top-20 u-flex">
						<u-image :src="item.headimg" width="80" height="80" shape="circle"></u-image>
						<view class="u-margin-left-20 ">
							<view class="u-font-weight">{{item.nickname}}</view>
							<view class="u-type-info u-font-22">{{item.mobile}}</view>
						</view>
					</view>

					<view class="u-flex u-row-between u-margin-top-20">

						<view class="u-type-info ">{{item.createTime}}</view>
						<view class="u-type-info">{{item.cardName}}/使用时长{{item.freeTime}}分钟</view>
					</view>

				</view>
			</u-swipe-action>



		</view>

	</view>
</template>

<script>
	import loader from '@/common/loadPage.js';


	export default {
		mixins: [loader],
		data() {
			return {
				options: [
					{
						text: '删除',
						style: {
							backgroundColor: '#dd524d'
						}
					}
				],
				user: {},
				list: [],
				initial: {
					geturl: "/alliance/userCard",
					parm: {
keywords:""
					},
					isPage: true
				},

			}
		},
		onLoad() {

		},
		onShow() {
			this.getUser();
			this.getGoods();
		},
		methods: {
			change(e){
				this.initial.parm.keywords=e;
				this.list=[];
				this.initial.page=1;
				this.getGoods();
			},
			click(index, index1) {
				
				this.$u.post('/alliance/userCardDel', {
					member_card_id: this.list[index].id
				}).then(res => {
					this.initial.page=1;
					this.list=[];
					this.getGoods();
				})
			
			},
			// 如果打开一个的时候，不需要关闭其他，则无需实现本方法
			open(index) {
				// 先将正在被操作的swipeAction标记为打开状态，否则由于props的特性限制，
				// 原本为'false'，再次设置为'false'会无效
				this.list[index].show = true;
				this.list.map((val, idx) => {
					if (index != idx) this.list[idx].show = false;
				})
			},
		
			getUser() {
				this.$u.post('/alliance/info').then(res => {
					this.user = res;
				})

				// this.$u.api.userInfo().then(res => {

				// })
			},
		}
	}
</script>

<style>
</style>